package com.bytedance.article.common.a.c;

import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.bytedance.frameworks.core.thread.e;

import org.json.JSONObject;

import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import inline.ScreenshotListener;
import inline.NetworkDemo;

public final class b extends e {
    private final String a;
    private final long b;

    public b(String arg1, long arg2) {
        this.a = arg1;
        this.b = arg2;
    }

    public final void run() {
        Object v0_2;
        try {
            ScreenshotListener v2 = c.a(this.a);
            ArrayList v4 = new ArrayList();
            Iterator v5 = v2.c().iterator();
            long v2_1;
            long v0_1 = 0L;
            for (v2_1 = 0; v5.hasNext(); v2_1 = v0_1) {
                File v6 = new File((String) v5.next());
                v0_1 = v6.length() + v2_1;
                if (v0_1 > this.b) {
                    return;
                }

                ((List) v4).add(v6);
            }

            Iterator v2_2 = ((List) v4).iterator();
            while (true) {
                label_22:
                if (!v2_2.hasNext()) {
                    return;
                }
                v0_2 = v2_2.next();
                ((File) v0_2).getAbsolutePath();
                String v1 = com.bytedance.framwork.core.monitor.c.j().k;
                if (TextUtils.isEmpty(((CharSequence) v1))) {
                    v1 = "http://amfr.snssdk.com/file_report/upload";
                }

                com.bytedance.framwork.core.monitor.c.j();
                if (!"success".equalsIgnoreCase(new JSONObject(NetworkDemo.a(com.bytedance.framwork.core.monitor.c.d(v1), ((File) v0_2), "UTF-8")).optString("message"))) {
                    continue;
                }
                ((File) v0_2).delete();
                continue;
            }
        } catch (Throwable v0) {
            v0.printStackTrace();
        }
    }

    @Override
    public void f(@NonNull Object o) {

    }
}

